package com.spi.soconversion.orders.conversion;

import com.spi.soconversion.util.SOCConstants;
import com.spi.soconversion.util.SOCUtility;
import com.spi.soconversion.util.XMLAttributeConstants;
import com.spi.soconversion.util.XMLTagConstants;

public class InstallBaseNote {

	private final String createProgID=SOCConstants.EMPTY_STRING;
	private String createts;
	private String createUserID;
	private String noteText;
	private final String noteKey=SOCConstants.EMPTY_STRING;
	private final String referenceKey=SOCConstants.EMPTY_STRING;
	private final String lockID=SOCConstants.ZERO;
	
	public String getReferenceKey() {
		return referenceKey;
	}
	
		
	public String getNoteText() {
		this.noteText = SOCUtility.checkNull(noteText);
		if(noteText.length()>4000)
		{
			noteText = noteText.substring(0, 4000);
		}
		return noteText;
	}
	
	public void setNoteText(String noteText) {
		this.noteText = noteText;
	}
		
	public String getNoteKey() {
		return noteKey;
	}
	
		
	public String getCreateProgID() {
		return createProgID;
	}
	
	public void setCreatets(String createts) {
		this.createts = createts;
	}
		
	public String getCreatets() {
		return  SOCUtility.checkNull(createts);
	}
	
	public void setCreateUserID(String createUserID) {
		this.createUserID = createUserID;
	}
	
	public String getCreateUserID() {
		this.createUserID = SOCUtility.checkNull(createUserID);
		if(createUserID.length()>40)
		{
			createUserID = createUserID.substring(0, 40);
		}
		return createUserID;		
	}
	
	public String getLockID() {
		return lockID;
	}
		
	public String getModifyProgID() {
		return getCreateProgID();
	}
	
	public String getModifyts() {
		return getCreatets();
	}
		
	public String getModifyUserID() {
		return getCreateUserID();
	}
	
	@Override
	public String toString()
	{
		StringBuilder sb = new StringBuilder();
		
		sb.append(XMLTagConstants.START_TAG_HBC_NOTE);
		sb.append(SOCConstants.BLANK_STRING);
		sb.append(SOCUtility.getAttribute(XMLAttributeConstants.CREATE_PROG_ID, getCreateProgID()));
		
		sb.append(SOCConstants.BLANK_STRING);
		sb.append(SOCUtility.getAttribute(XMLAttributeConstants.CREATE_TS, getCreatets()));
		
		sb.append(SOCConstants.BLANK_STRING);
		sb.append(SOCUtility.getAttribute(XMLAttributeConstants.CREATE_USER_ID, SOCUtility.replaceXMLSpecialCharacters(getCreateUserID())));
		
		sb.append(SOCConstants.BLANK_STRING);
		sb.append(SOCUtility.getAttribute(XMLAttributeConstants.INSTALL_BASE_NOTE_TEXT,  SOCUtility.replaceXMLSpecialCharacters(getNoteText())));
		
		sb.append(SOCConstants.BLANK_STRING);
		sb.append(SOCUtility.getAttribute(XMLAttributeConstants.INSTALL_BASE_NOTES_KEY, getNoteKey()));
		
		sb.append(SOCConstants.BLANK_STRING);
		sb.append(SOCUtility.getAttribute(XMLAttributeConstants.INSTALL_BASE_REFERENCE_KEY,getReferenceKey()));
		
		sb.append(SOCConstants.BLANK_STRING);
		sb.append(SOCUtility.getAttribute(XMLAttributeConstants.LOCK_ID, getLockID()));
		
		sb.append(SOCConstants.BLANK_STRING);
		sb.append(SOCUtility.getAttribute(XMLAttributeConstants.MODIFY_PROGID, getModifyProgID()));
		
		sb.append(SOCConstants.BLANK_STRING);
		sb.append(SOCUtility.getAttribute(XMLAttributeConstants.MODIFY_TS, getModifyts()));
		
		sb.append(SOCConstants.BLANK_STRING);
		sb.append(SOCUtility.getAttribute(XMLAttributeConstants.MODIFY_USER_ID, getModifyUserID()));
		
		sb.append(SOCConstants.CLOSING_XML_TAG);
		sb.append(SOCConstants.NEW_LINE);
		
		sb.append(XMLTagConstants.END_TAG_HBC_NOTE);
		
		return sb.toString();
	}
}
